<?php 
$template = $this->get_data('template');
$template = (empty($template)) ? '' : (string) $template;
?>
<div id="tpl_page">
<h2>Select Page Template</h2>
<select id="page_template" onchange="template_changed(this);">
    <option value=""></option>
    <?php foreach (m('app')->get_tpl_files('page') as $tpl_name): ?>
        <option <?php echo ($template == $tpl_name) ? 'selected="selected"' : '';?> value="<?php echo $tpl_name?>"><?php echo $tpl_name?></option>
    <?php endforeach;?>
</select>
</div>
<script type="text/javascript">
<?php if ('add' == tos_http_get('a')) : ?>
z.addEvent(document.body, 'load', function () {
    knm.add_require('template');
});
<?php endif; ?>


function template_changed(target) {
    knm.set('template', target.value);
}
</script>